{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "# necessary libraries\n",
    "\n",
    "import numpy as np\n",
    "from keras.layers import Dense, Flatten, Dropout, Input, BatchNormalization, PReLU\n",
    "from keras.utils import np_utils\n",
    "from keras.models import Sequential, Model\n",
    "from keras import regularizers\n",
    "import torch\n",
    "from keras import optimizers\n",
    "from keras.callbacks import ModelCheckpoint\n",
    "from keras.layers.merge import concatenate\n",
    "from keras.utils import to_categorical\n",
    "from keras import initializers\n",
    "\n",
    "import copy\n",
    "import os\n",
    "os.environ[\"CUDA_DEVICE_ORDER\"]=\"PCI_BUS_ID\"\n",
    "import threading\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### text embeddings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle\n",
    "with open('../politifact/finalTrainEmbeddings.pkl', 'rb') as f:\n",
    "    trainEmbeddings = pickle.load(f)\n",
    "with open('../politifact/finalTestEmbeddings.pkl', 'rb') as f:\n",
    "    testEmbeddings = pickle.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "with open('../imageDataset/politi/trainJson.json', 'r') as f:\n",
    "    trainData = json.load(f)\n",
    "with open('../imageDataset/politi/testJson.json', 'r') as f:\n",
    "    testData = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in trainEmbeddings:\n",
    "    trainEmbeddings[i] = [torch.mean(j[0], axis=1) for j in trainEmbeddings[i]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in testEmbeddings:\n",
    "    testEmbeddings[i] = [torch.mean(j[0], axis=1) for j in testEmbeddings[i]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in testEmbeddings:\n",
    "    temp = testEmbeddings[i]\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in trainEmbeddings:\n",
    "    if len(trainEmbeddings[i]) >=50:\n",
    "        trainEmbeddings[i] = trainEmbeddings[i][0:50]\n",
    "    else:\n",
    "        deficit = 50 - len(trainEmbeddings[i])\n",
    "        for j in range(deficit):\n",
    "            trainEmbeddings[i].append(torch.zeros((1,768), dtype=torch.float32, device='cuda:0'))\n",
    "    temp = torch.empty(50,768, dtype=torch.float32, device='cuda:0')\n",
    "    for j in range(len(trainEmbeddings[i])):\n",
    "        temp[j][:] = trainEmbeddings[i][j]\n",
    "    trainEmbeddings[i] = temp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### image embeddings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('politifact/train_vgg_poli.pickle', 'rb') as f:\n",
    "    train_vgg_poli = pickle.load(f)\n",
    "with open('politifact/test_vgg_poli.pickle', 'rb') as f:\n",
    "    test_vgg_poli = pickle.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in testEmbeddings:\n",
    "    if len(testEmbeddings[i]) >=50:\n",
    "        testEmbeddings[i] = testEmbeddings[i][0:50]\n",
    "    else:\n",
    "        deficit = 50 - len(testEmbeddings[i])\n",
    "        for j in range(deficit):\n",
    "            testEmbeddings[i].append(torch.zeros((1,768), dtype=torch.float32, device='cuda:0'))\n",
    "    temp = torch.empty(50,768, dtype=torch.float32, device='cuda:0')\n",
    "    for j in range(len(testEmbeddings[i])):\n",
    "        temp[j][:] = testEmbeddings[i][j]\n",
    "    testEmbeddings[i] = temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_text = []\n",
    "train_label = []\n",
    "test_text = []\n",
    "test_label = []\n",
    "train_image = []\n",
    "test_image = []\n",
    "testEmbedOrder = []\n",
    "testImageOrder = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in train_vgg_poli:\n",
    "    for j in trainData:\n",
    "        if i.split('.jpg')[0] == trainData[j][-1]['Top_img']:\n",
    "            train_text.append(trainEmbeddings[j])\n",
    "            train_image.append(train_vgg_poli[trainData[j][-1]['Top_img'] + '.jpg'])\n",
    "            train_label.append(trainData[j][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in test_vgg_poli:\n",
    "    for j in testData:\n",
    "        if i.split('.jpg')[0] == testData[j][-1]['Top_img']:\n",
    "            test_text.append(testEmbeddings[j])\n",
    "            test_image.append(test_vgg_poli[testData[j][-1]['Top_img'] + '.jpg'])\n",
    "            test_label.append(testData[j][0])\n",
    "            testEmbedOrder.append(j)\n",
    "            testImageOrder.append(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(381, 381, 381)"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(train_text), len(train_image), len(train_label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(104, 104, 104, 104, 104)"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(test_text), len(test_image), len(test_label), len(testEmbedOrder), len(testImageOrder)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "321 164\n"
     ]
    }
   ],
   "source": [
    "realCount = 0\n",
    "fakeCount = 0\n",
    "for i in train_label:\n",
    "    if i == 1:\n",
    "        realCount += 1\n",
    "    elif i == 0:\n",
    "        fakeCount += 1\n",
    "\n",
    "for i in test_label:\n",
    "    if i == 1:\n",
    "        realCount += 1\n",
    "    elif i == 0:\n",
    "        fakeCount += 1\n",
    "\n",
    "print(realCount, fakeCount)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "discreteTest = copy.deepcopy(test_label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_label = to_categorical(train_label)\n",
    "test_label = to_categorical(test_label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_text=[torch.Tensor.numpy(i.cpu()) for i in train_text]\n",
    "test_text=[torch.Tensor.numpy(i.cpu()) for i in test_text]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_text_matrix = np.ndarray(shape=(len(train_text), 50,768))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "counter = 0\n",
    "for i in train_text:\n",
    "    train_text_matrix[counter][:][:] = i\n",
    "    counter += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_text_matrix = np.ndarray(shape=(len(test_text), 50,768))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "counter = 0\n",
    "for i in test_text:\n",
    "    test_text_matrix[counter][:][:] = i\n",
    "    counter += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(104, 50, 768)"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_text_matrix.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 4096)"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_image[0].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_image_matrix = np.ndarray(shape=(len(train_image), 4096,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "counter = 0\n",
    "for i in train_image:\n",
    "    train_image_matrix[counter][:][:] = i.reshape(4096,1)\n",
    "    counter += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_image_matrix = np.ndarray(shape=(len(test_image), 4096,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "counter = 0\n",
    "for i in test_image:\n",
    "    test_image_matrix[counter][:][:] = i.reshape(4096,1)\n",
    "    counter += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_image_matrix = train_image_matrix.reshape(381,4096)\n",
    "test_image_matrix = test_image_matrix.reshape(104,4096)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Inference"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.models import load_model\n",
    "model = load_model('/root/autodl-tmp/checkpoints_polity/dense_MM_model.pt')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "predictions = model.predict(test_text_matrix)\n",
    "predictions = predictions.argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = []\n",
    "for i in range(len(test_label)):\n",
    "    data.append([testEmbedOrder[i],testEmbedOrder[i]testImageOrder[i],discreteTest[i],predictions[i]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pandas import DataFrame\n",
    "df_text = DataFrame.from_records(data)\n",
    "df_text.columns = [\"Text\", \"image\" ,\"true\", \"predicted\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Text</th>\n",
       "      <th>image</th>\n",
       "      <th>true</th>\n",
       "      <th>predicted</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>11</td>\n",
       "      <td>Statement from FDA Commissioner Scott Gottlieb...</td>\n",
       "      <td>2ZeChs9A2quWZsdZJKgl4geNCyWa6zeG.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>19</td>\n",
       "      <td>Singer Tina Turner: “This Thanksgiving Is The ...</td>\n",
       "      <td>6RT0ZrwHa1M1PKp2LJLtQ3vtNB2I04WP.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>23</td>\n",
       "      <td>9 celebrities who say they'll move to Canada i...</td>\n",
       "      <td>8AilY2mcf50mFUK3IAafUwowq4UAqJwF.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>42</td>\n",
       "      <td>Facebook 移動:\\n\\nこのメニューを開くには、 alt と / を同時に押してください</td>\n",
       "      <td>K0hYc0QUiOEge0AddBl5h7prDoD8J7lv.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>66</td>\n",
       "      <td>The pro-Russia, pro-weed, pro-Assange GOP cong...</td>\n",
       "      <td>TeogG4pmmN0XcgQpVvKJ8zy5iFYCyvda.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>67</td>\n",
       "      <td>Who is affected by the government shutdown? Th...</td>\n",
       "      <td>aWaQJnj5j2H1bGabLgXI9iERn1nR7xxA.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>71</td>\n",
       "      <td>Debbie Wasserman Schultz Aide Arrested Trying ...</td>\n",
       "      <td>CDN8vxK3zSoEskVpkfvSpD392IL8iVK8.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>73</td>\n",
       "      <td>Trump Nation 移動:\\n\\nこのメニューを開くには、 alt と / を同時に押...</td>\n",
       "      <td>cIfs4dD4PuddiDvWjISPL3kWN9L5enLL.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>75</td>\n",
       "      <td>Puerto Rico Mayor Facing Fraud Charges Over Mi...</td>\n",
       "      <td>cnXac0ALxV3kUdcBiliAE8cr1SwtGPOI.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>78</td>\n",
       "      <td>FBI uncovered Russian bribery plot before Obam...</td>\n",
       "      <td>Cz7c5ggpRSzjFC3xiekzmUyW48ekDtOS.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>88</td>\n",
       "      <td>Laguna Beach Antifa 22m David Hogg Didn't Atte...</td>\n",
       "      <td>TY4yFFwuzTvyRqKRUQ9YauBZeemTtlZ7.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>101</td>\n",
       "      <td>Actress Sandra Bullock to Hillary Clinton if Y...</td>\n",
       "      <td>yePBnY2QnoPH3nfG25XkIKeV5a8aI9GA.jpg</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                  Text  \\\n",
       "11   Statement from FDA Commissioner Scott Gottlieb...   \n",
       "19   Singer Tina Turner: “This Thanksgiving Is The ...   \n",
       "23   9 celebrities who say they'll move to Canada i...   \n",
       "42    Facebook 移動:\\n\\nこのメニューを開くには、 alt と / を同時に押してください   \n",
       "66   The pro-Russia, pro-weed, pro-Assange GOP cong...   \n",
       "67   Who is affected by the government shutdown? Th...   \n",
       "71   Debbie Wasserman Schultz Aide Arrested Trying ...   \n",
       "73   Trump Nation 移動:\\n\\nこのメニューを開くには、 alt と / を同時に押...   \n",
       "75   Puerto Rico Mayor Facing Fraud Charges Over Mi...   \n",
       "78   FBI uncovered Russian bribery plot before Obam...   \n",
       "88   Laguna Beach Antifa 22m David Hogg Didn't Atte...   \n",
       "101  Actress Sandra Bullock to Hillary Clinton if Y...   \n",
       "\n",
       "                                    image  true  predicted  \n",
       "11   2ZeChs9A2quWZsdZJKgl4geNCyWa6zeG.jpg     0          1  \n",
       "19   6RT0ZrwHa1M1PKp2LJLtQ3vtNB2I04WP.jpg     0          1  \n",
       "23   8AilY2mcf50mFUK3IAafUwowq4UAqJwF.jpg     0          1  \n",
       "42   K0hYc0QUiOEge0AddBl5h7prDoD8J7lv.jpg     0          1  \n",
       "66   TeogG4pmmN0XcgQpVvKJ8zy5iFYCyvda.jpg     0          1  \n",
       "67   aWaQJnj5j2H1bGabLgXI9iERn1nR7xxA.jpg     0          1  \n",
       "71   CDN8vxK3zSoEskVpkfvSpD392IL8iVK8.jpg     0          1  \n",
       "73   cIfs4dD4PuddiDvWjISPL3kWN9L5enLL.jpg     0          1  \n",
       "75   cnXac0ALxV3kUdcBiliAE8cr1SwtGPOI.jpg     0          1  \n",
       "78   Cz7c5ggpRSzjFC3xiekzmUyW48ekDtOS.jpg     0          1  \n",
       "88   TY4yFFwuzTvyRqKRUQ9YauBZeemTtlZ7.jpg     0          1  \n",
       "101  yePBnY2QnoPH3nfG25XkIKeV5a8aI9GA.jpg     0          1  "
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_text.loc[df_text['true'] < df_text['predicted']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Who is affected by the government shutdown? Thousands of government workers are unsure whether or not they will be heading to work on Monday amid uncertainty about how long a government shutdown will last.\\n\\nUncertainty is the byproduct of a government shutdown, with its impact often hard to predict. However, clues exist in the last shutdown, which was in 2013.\\n\\nKey services will continue, and many agencies plan to use carryover funds to remain open for several days. But each day the shutdown lasts adds to the pressure on agencies, government employees and civilian contractors, as well as Americans who rely on various federal services.\\n\\nEmployees considered “essential” will still be required to report to work should the shutdown continue, while those in positions deemed “nonessential” will be barred from coming in.\\n\\nThe White House on Friday pledged to minimize the effects of the shutdown on the American people, with one official noting that the administration has urged government agencies “to do as much as they can” within the law to maintain operations.\\n\\nThe push for departments and agencies to utilize existing funding to remain open suggests the Trump administration is hedging its bets that lawmakers can reach a deal and avoid a shutdown the length of one in 2013, which lasted 16 days.\\n\\nADVERTISEMENT\\n\\nEach federal agency has a contingency plan for a shutdown that is written with help from the White House’s Office of Management and Budget. But the impact of the shutdown, which began at midnight when the Senate failed to pass a short-term spending bill, is likely to trickle down gradually as agencies work to mitigate the effects.\\n\\nAbout half of the Department of Health and Human Services will be placed on furlough. Beneficiaries of programs like Medicare, Social Security and Medicaid will still receive services. The Food and Drug Administration, however, will take a hit, as it will have to halt activities like food safety inspections. The Centers for Disease Control and Prevention will continue “immediate response work” on influenza, according to White House budget chief Mick Mulvaney John (Mick) Michael MulvaneyBottom line This week: Barr back in hot seat over Mueller report GOP senator 'concerned' about Russian interference MORE.\\n\\nThe National Park Service (NPS) will keep parks open, unlike in 2013, though much of its staff will not report to work. Services such as trash pickup and restroom cleaning will be halted, according to the NPS contingency plan for a shutdown.\\n\\nCybersecurity will remain a priority during the shutdown, as the government will continue to protect information technology systems, Mulvaney said Saturday at a press conference.\\n\\nThe Environmental Protection Agency will largely stay open during the government's closure, and the Labor Department will resume mine safety inspections.\\n\\nMilitary personnel will be required to show up for work, but will not receive pay for as long as the shutdown lasts. Families of slain military members will experience a halt to death benefits as a result of the shutdown.\\n\\nTransportation Security Administration (TSA) personnel will continue operations, meaning travelers will see both TSA employees and canines operating in airports. The Federal Aviation Administration’s (FAA) management of air traffic control will also continue. Flight delays are not expected and much of the FAA's safety inspections will continue.\\n\\nThe government closure, a result of Congress’s failed negotiations over a spending bill the last several weeks, has sparked both intraparty battles and fights between Democrats and Republicans.\\n\\nThe two parties have each tried to cast blame on the other for the shutdown, with the Republican National Committee invoking the hashtag #SchumerShutdown, referring to Senate Minority Leader Charles Schumer Charles (Chuck) Ellis SchumerSchumer jokes NY Times erred in crossword clue: 'Chuck' has 'five letters!' MJ Hegar announces Texas Senate bid Hillicon Valley: House Dems subpoena full Mueller report | DOJ pushes back at 'premature' subpoena | Dems reject offer to view report with fewer redactions | Trump camp runs Facebook ads about Mueller report | Uber gets B for self-driving cars MORE (D-N.Y.). Democrats say President Trump Donald John TrumpOnly one way with Huawei — don't let it control 5G Japan's emperor is first to abdicate throne in two centuries Air Force secretary warns against European military force MORE is to blame for the closure, which follows failed talks over immigration and health-care funding.\\n\\nWhat happens next depends on whether lawmakers reach a deal, as members of both the House and Senate have remained in Washington, D.C., to work toward an agreement to open the government.\\n\\nLeaders in opposing parties on Saturday appear to be at odds over a short-term resolution to fund the government. Both chambers returned to Capitol Hill on Saturday afternoon to work toward a solution.\""
      ]
     },
     "execution_count": 129,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_text.iloc[67]['Text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [],
   "source": [
    "modelMM = load_model('checkpoints_polity/dense_MM_model.hdf5')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [],
   "source": [
    "predictions2 = modelMM.predict([test_text_matrix, test_image_matrix])\n",
    "predictions2 = predictions2.argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [],
   "source": [
    "data2 = []\n",
    "for i in range(len(test_label)):\n",
    "    data2.append([testEmbedOrder[i],testImageOrder[i],discreteTest[i],predictions2[i]])\n",
    "from pandas import DataFrame\n",
    "df_MM = DataFrame.from_records(data2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    Who is affected by the government shutdown? Th...\n",
       "1                 aWaQJnj5j2H1bGabLgXI9iERn1nR7xxA.jpg\n",
       "2                                                    0\n",
       "3                                                    0\n",
       "Name: 67, dtype: object"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_MM.iloc[67]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[24  5]\n",
      " [11 64]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUMAAAEQCAYAAAAqKRZeAAAAB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Oh7HtPFXTsiwTAiuqLXBlDkHhvenihJ9wN3dbscbTAXWNvtQsSYbK2f2TNt7zyRDCRdQvX+NGOt7aE3fGq5rS4Ybq0kXTeRS59H5+Uzm1xycdeICBIMIyKABMPJZLRbI0bvyWc2iSQYThJN3Ce2rSQNSFou6RZJ/ybpKRPIa5Gki8rjoySd2iDtHEn/fRzHOE3SyeMtYyt0+zOLsUkwjGZttL3Q9n7A48A76neqMubvk+0LbTe6Wc8cYMzBMGKsEgxjPH4K7CVpvqRfSvp/wC3A7pIWS1om6YZSg5wFIOkISbdLugH4b7WMJL1V0hfL43mSzpd0U1leQHVXsz1LrfQfS7oPSLpW0s2SPlKX199J+pWknwF7d+zdiK1CJl3HmEiaCrwcuKRsWgAssX2VpLnAh4HDbG+QdApwkqRPA18BDgHuAM4dIfvPAz+x/WpJU4BZwKnAfrYXluMvLsc8CBBwoaSXABuA1wMLqb7XNwDXt/bVx9YswTCaNUPS8vL4p8CZwNOBu2xfVbYfDOwL/FwSwLZU97PdB/it7ZUAks4BThjmGIcAbwGwPQD8QdJTh6RZXJYby/osquA4Gzjf9iPlGBdO6NVG30kwjGZtrNXOakrA21C/Cbhs6H1sJW3xvAkS8EnbXx5yjPe28BjRh9JnGK10FfBCSXsBSJop6dnA7cB8SXuWdCPd9Pty4J3luVMk7QA8RFXrq7kUOK6uL3I3SbsAVwLHSJohaTbwqha/ttjKJRhGy9i+H3gr8A1JN1OayLYfpWoWf68MoKwZIYv3AC+V9Auq/r59ba+janbfIukfbf8A+DqwrKQ7D5ht+waqvsibgO8D17bthcZWKecmR0SQmmFEBJBgGBEBJBhGRAAJhhERQIJhRASQYBgRASQYRkQA8B8oQgBtwBZ7BQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.metrics import confusion_matrix\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "labels = ['Real', 'Fake']\n",
    "cm = confusion_matrix(discreteTest, predictions2)\n",
    "print(cm)\n",
    "fig = plt.figure()\n",
    "ax = fig.add_subplot(111)\n",
    "cax = ax.matshow(cm)\n",
    "plt.title('Confusion matrix of the classifier')\n",
    "fig.colorbar(cax)\n",
    "ax.set_xticklabels([''] + labels)\n",
    "ax.set_yticklabels([''] + labels)\n",
    "plt.xlabel('Predicted')\n",
    "plt.ylabel('True')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Uninstalling matplotlib-2.2.3:\n",
      "  Would remove:\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/matplotlib-2.2.3-py3.7-nspkg.pth\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/matplotlib-2.2.3.dist-info/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/matplotlib/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/mpl_toolkits/axes_grid/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/mpl_toolkits/axes_grid1/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/mpl_toolkits/axisartist/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/mpl_toolkits/mplot3d/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/mpl_toolkits/tests/*\n",
      "    /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages/pylab.py\n",
      "Proceed (y/n)? ^C\n",
      "\u001b[31mERROR: Operation cancelled by user\u001b[0m\n",
      "Collecting pip\n",
      "  Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl\n",
      "Installing collected packages: pip\n",
      "  Found existing installation: pip 19.2.2\n",
      "    Uninstalling pip-19.2.2:\n",
      "      Successfully uninstalled pip-19.2.2\n",
      "Successfully installed pip-19.2.3\n",
      "Requirement already satisfied: matplotlib in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (2.2.3)\n",
      "Requirement already satisfied: cycler>=0.10 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (0.10.0)\n",
      "Requirement already satisfied: numpy>=1.7.1 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (1.16.5)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (2.8.0)\n",
      "Requirement already satisfied: six>=1.10 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (1.12.0)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (2.4.2)\n",
      "Requirement already satisfied: pytz in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (2019.2)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from matplotlib) (1.1.0)\n",
      "Requirement already satisfied: setuptools in /home/karmanya/.conda/envs/deepBert/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (41.0.1)\n"
     ]
    }
   ],
   "source": [
    "!pip uninstall matplotlib\n",
    "!python -m pip install --upgrade pip\n",
    "!pip install matplotlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python (BERT)",
   "language": "python",
   "name": "bert"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
